package com.nereyda.controller
{
	import com.nereyda.events.calendar.*;
	import com.nereyda.events.documents.UploadDocumentEvent;
	import com.nereyda.events.login.*;
	import com.nereyda.events.misc.*;
	import com.nereyda.events.users.*;
	import com.nereyda.responses.calendar.*;
	import com.nereyda.responses.documents.UploadDocumentSO;
	import com.nereyda.responses.login.*;
	import com.nereyda.responses.misc.*;
	import com.nereyda.responses.users.*;
	import org.moyrax.nereyda.services.core.FrontMapper;

	/**
	 * Esta clase se encargará de inicializar los mapeos de
	 * los objetos de servicio con su respectivo servicio.
	 */
	public class MappingController extends FrontMapper
	{
		// Lista de servicios disponibles.
		//
		public static const LOGIN_SERVICE     :String = "LoginService";
		public static const CALENDAR_SERVICE  :String = "CalendarService";
		public static const DOCUMENTS_SERVICE :String = "DocumentsService";
		
		private static var instance :MappingController = null;
		
		public static function getInstance():MappingController
		{
			if ( instance == null )
				instance = new MappingController();
			
			return( instance );
		}
		
		// Constructor.
		//
		public function MappingController():void
		{
			this.mapServiceObjects();
		}
		
		/**
		 * En esta función se especificarán todos los mapeos a objetos 
		 * que se harán desde la respuesta de los servicios.
		 */
		private function mapServiceObjects():void
		{
			this.mapObject( "CurSection", CurSectionSO, MiscCurSectionEvent );
			this.mapObject( "UsersService", UserSO, UsersGetListEvent );

			// Servicio de gestión de sesiones.
			//
			this.mapObject( LOGIN_SERVICE, LoginSO, LoginEvent );
			this.mapObject( LOGIN_SERVICE, CheckForSessionSO, CheckForSessionEvent );
			this.mapObject( LOGIN_SERVICE, LogoutSO, LogoutEvent );

			// Servicio de agenda.
			//
			this.mapObject( CALENDAR_SERVICE, GetCategoriesSO,  GetCategoriesEvent );
			this.mapObject( CALENDAR_SERVICE, GetEventsByCategorySO, GetEventsByCategoryEvent );
			this.mapObject( CALENDAR_SERVICE, CreateCategorySO, CreateCategoryEvent );
			this.mapObject( CALENDAR_SERVICE, CreateEventSO,    CreateEventEvent);
			this.mapObject( CALENDAR_SERVICE, UpdateCategorySO, UpdateCategoryEvent );
			this.mapObject( CALENDAR_SERVICE, UpdateEventSO,    UpdateEventEvent );
			this.mapObject( CALENDAR_SERVICE, DeleteCategorySO, DeleteCategoryEvent );
			this.mapObject( CALENDAR_SERVICE, DeleteEventSO,    DeleteEventEvent );

			// Servicio de documentos.
			//
			this.mapObject( DOCUMENTS_SERVICE, UploadDocumentSO, UploadDocumentEvent );
		}
	}
}